<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>

<head>
<title><spring:message code="admin.viewroles.title" /></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script src="<c:url value="/javascripts/common.js"/>"></script>
<script language="javascript" type="text/javascript">
function activateRow(index,ele)
{
	var ok = confirm( ((ele.checked)?'Activate':'De-activate') +  " this roles?");
	if(!ok)
	  ele.checked = !ele.checked;
	else
	  document.location.href = "update_status_roles.htm?id="+ele.value+"&active="+ele.checked+"&rd="+new Date().getTime();	  	
}
</script>
<script language="javascript">
// script added by Umme Essa. The form should be validated on all operations.
	 var functionName="";
	 function validateForm(){ 
		if(!isAnyCheckBoxSelected("selector")) {
			alert("Please select a record to delete");
			return false;
		}
		return true;
	 }
 
	 function isAnyCheckBoxSelected(selecter){
		 var items = document.forms[0].elements[selecter];
		 var length=getLength(items);
		 var item=null;
		 	for(i=0;i<length;i++)
		 	{	item=getItemAt(items,i);
		 		if(item.checked)
		 			return true;
		 	}
		 return false;
		 }

	 function edit( id , isClone){
	     var url = 'edit_bonus.htm?id='+id+'&clone='+isClone;
	     document.location.href = url;
	 }
	 </script>
</head>

<body><%@include file="../top_menu.jsp"%>

<table width=100%>
	<tr>
		<td><%@include file="/WEB-INF/jsp/menu/admin_role_menu.jsp"%>
		<br />
		</td>
	</tr>
	<tr>
		<td><%@include file="/WEB-INF/jsp/include/messages.jsp"%>
		<br />
		</td>
	</tr>
</table>
<form action="delete_roles.htm" method="post"
	onsubmit="return validateForm()">
<table width=70% class="formTable" cellspacing="0">
	<tr class="ui-state-default">
		<c:if test="${roleList.pageNumber>1}">
			<td align="left"><a
				href="view_roles.htm?pageNo=${roleList.pageNumber-1}&sortColumn=${roleList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-prev"
				style="float: left;"></span><spring:message code="admin.viewroles.button.previouspage" /></a></td>
		</c:if>
		<c:if test="${roleList.pageNumber<roleList.pagesAvailable}">
			<td align="right"><a
				href="view_roles.htm?pageNo=${roleList.pageNumber+1}&sortColumn=${roleList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-next"
				style="float: right;"></span><spring:message code="admin.viewroles.button.nextpage" /></a></td>
		</c:if>
	</tr>
</table>
<table width=70% class="formTable">
	<tr class="formHeader">
		<td colspan="6"><spring:message code="admin.viewroles.label.roles" /></td>
	</tr>
	<tr>
		<td align="center"><input type="checkbox"
			onclick="ch_select(this.checked)" /></td>
		<th><a	href="view_roles.htm?pageNo=${roleList.pageNumber}&sortColumn=id&sortOrder=${roleList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${roleList.sortOrder}"><spring:message code="admin.viewroles.label.roleid" /></a></th>
		<th><a	href="view_roles.htm?pageNo=${roleList.pageNumber}&sortColumn=name&sortOrder=${roleList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${roleList.sortOrder}"><spring:message code="admin.viewroles.label.rolename" /></a></th>
		<th><a	href="view_roles.htm?pageNo=${roleList.pageNumber}&sortColumn=description&sortOrder=${roleList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${roleList.sortOrder}"><spring:message code="admin.viewroles.label.roledescription" /></a></th>
		<th><spring:message code="admin.viewroles.label.status" /></th>
		<th><a	href="view_roles.htm?pageNo=${roleList.pageNumber}&sortColumn=comments&sortOrder=${roleList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${roleList.sortOrder}"><spring:message code="admin.viewroles.label.comments" /></a></th>
	</tr>
	</thead>
	<tbody>
		<c:if test="${empty roleList}">
			<tr>
				<td colspan="6"><spring:message code="admin.viewroles.label.norecordswerefound" /></td>
			</tr>
		</c:if>

		<c:forEach var="r" items="${roleList.pageItems}" varStatus="i">
			<tr class="tr_record">
				<td align="center"><input type="checkbox" id="selector"
					class="Role" name="ids" value="${r.id}"></input></td>
				<td>${r.id}</td>
				<td><a
					href="<c:url value="/admin/role/edit_role.htm?id=${r.id}"/>">${r.name}</a></td>
				<td>${r.description}</td>
				<td><input type="checkbox" value="${r.id}"
					<c:if test="${r.active}">checked</c:if>
					onclick="activateRow(${i.index},this);" /></td>
				<td><c:out value="${r.comments}" default="" /></td>
			</tr>
		</c:forEach>
		<tr>
			<td colspan="6"><input type="submit"
				class='ui-button ui-state-default ui-corner-all' value="<spring:message code="admin.viewroles.button.remove" />" /></td>
		</tr>
	</tbody>
</table>
<table width=70% class="formTable" cellspacing="0">
	<tr class="ui-state-default">
		<c:if test="${roleList.pageNumber>1}">
			<td align="left"><a
				href="view_roles.htm?pageNo=${roleList.pageNumber-1}&sortColumn=${roleList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-prev"
				style="float: left;"></span><spring:message code="admin.viewroles.button.previouspage" /></a></td>
		</c:if>
		<c:if test="${roleList.pageNumber<roleList.pagesAvailable}">
			<td align="right"><a
				href="view_roles.htm?pageNo=${roleList.pageNumber+1}&sortColumn=${roleList.sortColumn}"
				class="mouseEffect"><span class="ui-icon ui-icon-seek-next"
				style="float: right;"></span><spring:message code="admin.viewroles.button.nextpage" /></a></td>
		</c:if>
	</tr>
</table>
</form>
<%@include file="/WEB-INF/jsp/include/footer.jsp"%>
</body>
</html>